import { RouteRecordRaw } from "vue-router";
import HomeView from "@/views/HomeView.vue";
import AboutView from "@/views/AboutView.vue";
import NoPowerView from "@/views/NoPowerView.vue";
import AdminVue from "@/views/AdminView.vue";
import userRole from "@/access/permissionEnum";
import LoginView from "@/views/LoginView.vue";
import RegisterView from "@/views/RegisterView.vue";
import UserAccount from "@/components/register/UserAccount.vue";
import UserInfo from "@/components/register/UserInfo.vue";
import UserOther from "@/components/register/UserOther.vue";
import AddQuestionView from "@/views/quesstion/AddQuestionView.vue";
import QuestionSubmitView from "@/views/quesstion/QuestionSubmitView.vue";
import WatchSubmitView from "@/views/quesstion/WatchSubmitView.vue";
import UserMannagerView from "@/views/user/UserMannagerView.vue";
import isErrorView from "@/error/isErrorView.vue";
import MineView from "@/views/MyHomeView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "题库",
    component: HomeView,
    meta: {
      icon: "icon-tiku",
    },
  },
  {
    path: "/nopower",
    name: "",
    component: NoPowerView,
    meta: {
      isHide: true,
    },
  },
  {
    path: "/login",
    name: "用户登录",
    component: LoginView,
    meta: {
      isHide: true,
      isOnly: true,
      access: userRole.NOT_LOGIN,
    },
  },
  {
    path: "/register",
    name: "用户注册",
    component: RegisterView,
    meta: {
      isHide: true,
      isOnly: true,
      access: userRole.NOT_LOGIN,
    },
    children: [
      {
        path: "",
        component: UserAccount,
      },
      {
        path: "userInfo",
        component: UserInfo,
      },
      {
        path: "userOther",
        component: UserOther,
      },
    ],
  },
  {
    path: "/admin",
    name: "题目提交管理",
    component: AdminVue,
    meta: {
      access: userRole.ADMIN,
      icon: "icon-timuguanli",
    },
  },
  {
    path: "/addQuestion",
    name: "添加题目",
    component: AddQuestionView,
    meta: {
      access: userRole.ADMIN,
      icon: "icon-tianjiatimu",
    },
  },
  {
    path: "/users",
    name: "用户管理",
    component: UserMannagerView,
    meta: {
      access: userRole.ADMIN,
      icon: "icon-yonghuguanli",
    },
  },
  {
    path: "/about",
    name: "关于我们",
    component: AboutView,
    meta: {
      icon: "icon-guanyuwomen",
    },
  },
  {
    path: "/submit",
    name: "题目提交",
    component: QuestionSubmitView,
    meta: {
      access: userRole.USER_FORMAT,
      isHide: true,
    },
  },
  {
    path: "/watch",
    name: "用户个人提交的页面",
    component: WatchSubmitView,
    meta: {
      access: userRole.ADMIN,
      isHide: true,
    },
  },
  {
    path: "/errLogin",
    name: "重复登录,注册",
    component: isErrorView,
    meta: {
      access: userRole.NOT_LOGIN,
      isHide: true,
    },
  },
  {
    path: "/mine",
    name: "个人主页",
    component: MineView,
    meta: {
      access: userRole.USER_FORMAT,
      isHide: true,
    },
  },
];
